Date.prototype.pattern = function(fmt) {
        var o = {
            "M+": this.getMonth() + 1, //月份  
            "d+": this.getDate(), //日  
            "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //小时  
            "H+": this.getHours(), //小时  
            "m+": this.getMinutes(), //分  
            "s+": this.getSeconds(), //秒  
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度  
            "S": this.getMilliseconds() //毫秒  
        };
        var week = {
            "0": "/u65e5",
            "1": "/u4e00",
            "2": "/u4e8c",
            "3": "/u4e09",
            "4": "/u56db",
            "5": "/u4e94",
            "6": "/u516d"
        };
        if (/(y+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        }
        if (/(E+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "/u661f/u671f" : "/u5468") : "") + week[this.getDay() + ""]);
        }
        for (var k in o) {
            if (new RegExp("(" + k + ")").test(fmt)) {
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            }
        }
        return fmt;
    }
    //定义一些常量
var x_PI = 3.14159265358979324 * 3000.0 / 180.0;
var PI = 3.1415926535897932384626;
var a = 6378245.0;
var ee = 0.00669342162296594323;

function out_of_china(lng, lat) {
    return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false);
}
var BXKK=`
    11010830001320030001,
    11010830001320030002,
    11010830001320030003,
    11010830001320030004,
    11010830001320030005,
    11010830001320030006,
    11010830001320030007,
    11010830001320030008,
    11010830001320030009,
    11010830001320030010,
    11010830001320030011,
    11010830001320030012,
    11010830001320030013,
    11010830001320030014,
    11010830001320030015,
    11010830001320030016,
    11010830001320030017,
    11010830001320030018,
    11010830001320030019,
    11010830001320030020,
    11010830001320030021,
    11010830001320030022,
    11010830001320030023,
    11010830001320030024,
    11010830001320030025,
    11010830001320030026,
    11010830001320030027,
    11010830001320030028,
    11010830001320030029,
    11010830001320030030,
    11010830001320030031,
    11010830001320030032,
    11010830001320030033,
    11010830001320030034,
    11010830001320030035,
    11010830001320030036,
    11010830001320030037,
    11010830001320030038,
    11010830001320030039,
    11010830001320030040,
    11010830001320030041,
    11010830001320030042,
    11010830001320030043,
    11010830001320030044,
    11010830001320030045,
    11010830001320030046,
    11010830001320030047,
    11010830001320030048,
    11010830001320030049,
    11010830001320030050,
    11010830001320030051,
    11010830001320030052,
    11010830001320030053,
    11010830001320030054,
    11010830001320030055,
    11010830001320030056,
    11010830001320030057,
    11010830001320030058,
    11010830001320030059,
    11010830001320030060,
    11010830001320030061,
    11010830001320030062,
    11010830001320030063,
    11010830001320030064,
    11010830001320030065,
    11010830001320030066,
    11010830001320030067,
    11010830001320030068,
    11010830001320030069,
    11010830001320030070,
    11010830001320030071,
    11010830001320030072,
    11010830001320030073,
    11010830001320030074,
    11010830001320030075,
    11010830001320030076,
    11010830001320030077,
    11010830001320030078,
    11010830001320030079,
    11010830001320030080,
    11010830001320030081,
    11010830001320030082,
    11010830001320030083,
    11010830001320030084,
    11010830001320030085,
    11010830001320030086,
    11010830001320030087,
    11010830001320030088,
    11010830001320030089,
    11010830001320030090,
    11010830001320030091,
    11010830001320030092,
    11010830001320030093,
    11010830001320030094,
    11010830001320030095,
    11010830001320030096,
    11010830001320030097,
    11010830001320030098,
    11010830001320030099,
    11010830001320030100,
    11010830001320030101,
    11010830001320030102,
    11010830001320030103,
    11010830001320030104,
    11010830001320030105,
    11010830001320030106,
    11010830001320030107,
    11010830001320030108,
    11010830001320030109,
    11010830001320030110,
    11010830001320030111,
    11010830001320030112,
    11010830001320030113,
    11010830001320030114,
    11010830001320030115,
    11010830001320030116,
    11010830001320030117,
    11010830001320030118,
    11010830001320030119,
    11010830001320030120,
    11010830001320030121,
    11010830001320030122,
    11010830001320030123,
    11010830001320030124,
    11010830001320030125,
    11010830001320030126,
    11010830001320030127,
    11010830001320030128,
    11010830001320030129,
    11010830001320030130,
    11010830001320030131,
    11010830001320030133,
    11010830001320030134,
    11010830001320030135,
    11010830001320030136,
    11010830001320030137,
    11010830001320030138,
    11010830001320030139,
    11010830001320030140,
    11010830001320030141,
    11010830001320030142,
    11010830001320030143,
    11010830001320030144,
    11010830001320030145,
    11010830001320030146,
    11010830001320030147,
    11010830001320030148`;
    BXKK=BXKK.split(",")

function unique(arr1) {
    const res = new Map();
    return arr1.filter((a) => !res.has(a.devId) && res.set(a.devId, 3))
  }
function transformlat(lng, lat) {
    var ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
    ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
    ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0;
    ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0;
    return ret
}

function transformlng(lng, lat) {
    var ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
    ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
    ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0;
    ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0;
    return ret
}

function bd09togcj02(bd_lon, bd_lat) {
    var x_pi = 3.14159265358979324 * 3000.0 / 180.0;
    var x = bd_lon - 0.0065;
    var y = bd_lat - 0.006;
    var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
    var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
    var gg_lng = z * Math.cos(theta);
    var gg_lat = z * Math.sin(theta);
    return [gg_lng, gg_lat]
}

function wgs84togcj02(lng, lat) {
    if (out_of_china(lng, lat)) {
        return [lng, lat]
    } else {
        var dlat = transformlat(lng - 105.0, lat - 35.0);
        var dlng = transformlng(lng - 105.0, lat - 35.0);
        var radlat = lat / 180.0 * PI;
        var magic = Math.sin(radlat);
        magic = 1 - ee * magic * magic;
        var sqrtmagic = Math.sqrt(magic);
        dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);
        dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);
        var mglat = lat + dlat;
        var mglng = lng + dlng;
        return [mglng, mglat]
    }
}
//判断是否等于113卡口
function IsBXKK(devid) {
    var num=0;
 $.each(BXKK,function(i,row){
     if(row.indexOf(devid)>=0){
        num+=1;
     }
 })
 return num;
}
var map = null;
/**
 * GCJ02 转换为 WGS84
 * @param lng
 * @param lat
 * @returns {*[]}
 */
function gcj02towgs84(lng, lat) {
    if (out_of_china(lng, lat)) {
        return [lng, lat]
    } else {
        var dlat = transformlat(lng - 105.0, lat - 35.0);
        var dlng = transformlng(lng - 105.0, lat - 35.0);
        var radlat = lat / 180.0 * PI;
        var magic = Math.sin(radlat);
        magic = 1 - ee * magic * magic;
        var sqrtmagic = Math.sqrt(magic);
        dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);
        dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);
        mglat = lat + dlat;
        mglng = lng + dlng;
        return [lng * 2 - mglng, lat * 2 - mglat]
    }
}
/**
 * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换
 * 即谷歌、高德 转 百度
 * @param lng
 * @param lat
 * @returns {*[]}
 */
function gcj02tobd09(lng, lat) {
    var z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * x_PI);
    var theta = Math.atan2(lat, lng) + 0.000003 * Math.cos(lng * x_PI);
    var bd_lng = z * Math.cos(theta) + 0.0065;
    var bd_lat = z * Math.sin(theta) + 0.006;
    return [bd_lng, bd_lat]
}
var devid = "";
var detailObj = {
    deviceArr: [],
    page: 1,
    loginId: '',
    sessionData: '',
    tppage: 1,
    totalPages: 0,
    index: -1, //工地地址
    dataArr: [],
    dwData1: [],
    dwData: [],
    plateColor: 0,
    GCMC: "",
    GCDZ: "",
    TFZL: "",
    ZYCBD: "",
    YSCD: "",
    TFXNC: "",
    SFXN: "",
    SFAZS: "",
    SFSZC: "",
    fanwei: "",
    fanwei: 0,
    num: "",
    point: "",
    zyz: "0",
    bool: 0,
    bool2: 0,
    ztcdevid: "",
    gdid: "",
    devid: [],
    JWDNumArr: [],
    deviceIds: '',
    functions: {
        init: function() {
            map = new BMap.Map("container");
            map.centerAndZoom(new BMap.Point(116.404, 39.915), 14);
            map.enableScrollWheelZoom(); //启用滚轮放大缩小，默认禁用
            map.enableContinuousZoom(); //启用地图惯性拖拽，默认禁用
            detailObj.functions.xnlx();
            detailObj.functions.initCondition();
            detailObj.gdid = detailObj.functions.getUrlParam("gdid");
            var begintime = detailObj.functions.getDateStr(-10) + " 00:00:00";
            var endtime = detailObj.functions.getCurrentDay();


            $("#siteAddress").text(detailObj.GCDZ);
            $("#GCMC").attr("title", detailObj.GCMC);
            $("#GCDZ").attr("title", detailObj.GCDZ);
            $("#TFZL").attr("title", detailObj.TFZL);
            $("#ZYCBD").attr("title", detailObj.ZYCBD);
            $("#YSCD").attr("title", detailObj.YSCD);
            $("#TFXNC").attr("title", detailObj.TFXNC);
            $("#SFXN").attr("title", detailObj.SFXN);
            $("#SFAZS").attr("title", detailObj.SFAZS);
            $("#SFSZC").attr("title", detailObj.SFSZC);
            $.ajax({
                type: "get",
                dataType: "json",
                async: false,
                data: {
                    id: detailObj.gdid
                },
                url: GDUrl + '/VIAS/web/snapshot/WorkSite/querySiteById',
                success: function(data) {
                    var row = data[0];
                    detailObj.GCMC = row.GCMC;
                    detailObj.GCDZ = row.GCJSDD;
                    detailObj.TFZL = row.GCXZNAME;
                    detailObj.ZYCBD = row.JSDWMC;
                    detailObj.YSCD = row.SGDW;
                    detailObj.TFXNC = row.JLDW;
                    detailObj.SFXN = row.STATE;
                    detailObj.point = detailObj.functions.getUrlParam("point");
                    $("#SGBH").text(row.SGXKZH);
                    $("#GCZJ").text(row.HTJG);
                    $("#JZMJ").text(row.YDMJ);
                    $("#GCMC").text(detailObj.GCMC);
                    $("#GCXZ").text(detailObj.TFZL);
                    $("#SGDW").text(detailObj.YSCD);
                    $("#GCDZ").text(detailObj.GCDZ);
                    $("#GCDZ1").text(detailObj.GCDZ);
                    $("#JSDW").text(detailObj.ZYCBD);
                    $("#JLDW").text(detailObj.TFXNC);
                    $("#SFXN").text(detailObj.SFXN);

                }
            })
            detailObj.functions.spkinof1();
            detailObj.functions.spkinof12();

        },
        prevDetail: function() {},
        nextDetail: function() {},
        pagesLeft: function() {
            if (detailObj.page > 1) {
                detailObj.page -= 1;
                detailObj.functions.getztcdata();
            }

        },
        pagesRight: function() {
            if (detailObj.page <= detailObj.totalPages) {
                detailObj.page += 1;
                detailObj.functions.getztcdata();
            }

        }, //轨迹上图
        GJinof: function(data) {
            if (data.message == "ok") {
                var pts = data.results[0].path.split(",");
                var points = [];
                for (var i = 0; i < pts.length; i += 2) {
                    points.push(new BMap.Point(pts[i], pts[i + 1]));
                }
                var polyline = new BMap.Polyline(points, { strokeWeight: 5, strokeColor: "red" });
                map.addOverlay(polyline);

            }
        },
        //消纳路线
        xnlx: function() {
            var point = this.getUrlParam("point");
            point = point.split(",")
            console.log(point);
            $.ajax({
                type: 'get',
                dataType: "json",
                data: {
                    gcmc: detailObj.GCMC
                },
                url: 'http://11.16.127.79:8013/VIAS/web/Accommodation/findByGcmc',
                success: function(data) {
                    if (data.length > 0) {
                        var p = wgs84togcj02(Number(point[1]), Number(point[0]));
                        p = gcj02tobd09(p[0], p[1]);
                        var start = new BMap.Point(p[0], p[1]);
                        var end = new BMap.Point(data[0].LNG, data[0].LAT);
                        var opts = {
                            position: start, // 指定文本标注所在的地理位置
                            offset: new BMap.Size(-(detailObj.GCMC.length * 13) / 2, 10) //设置文本偏移量
                        }
                        var label = new BMap.Label(detailObj.GCMC, opts); // 创建文本标注对象
                        label.setStyle({
                            color: "red",
                            fontSize: "12px",
                            height: "20px",
                            lineHeight: "20px",
                            fontFamily: "微软雅黑"
                        });
                        map.addOverlay(label);
                        var opts1 = {
                            position: end, // 指定文本标注所在的地理位置
                            offset: new BMap.Size(-(data[0].XNMC.length * 13) / 2, 10) //设置文本偏移量
                        }
                        var label1 = new BMap.Label(data[0].XNMC, opts1); // 创建文本标注对象
                        label1.setStyle({
                            color: "red",
                            fontSize: "12px",
                            height: "20px",
                            lineHeight: "20px",
                            fontFamily: "微软雅黑"
                        });
                        map.addOverlay(label1);
                        var myIcon = new BMap.Icon("images/siteBule30X30.png", new BMap.Size(20, 20)); // 设置图片偏移
                        myIcon.setImageSize(new BMap.Size(20, 20));
                        var marker = new BMap.Marker(start, { offset: new BMap.Size(0, 0), icon: myIcon });
                        map.addOverlay(marker); //
                        var myIcon1 = new BMap.Icon("images/ztc2.png", new BMap.Size(20, 20)); // 设置图片偏移
                        myIcon.setImageSize(new BMap.Size(20, 20));
                        var marker1 = new BMap.Marker(end, { offset: new BMap.Size(0, 0), icon: myIcon1 });
                        map.addOverlay(marker1); //
                        getGJinof(start, end, detailObj.functions.GJinof);
                        map.centerAndZoom(start, 10);
                    } else if (detailObj.GCMC != null) {

                        var p = wgs84togcj02(Number(point[1]), Number(point[0]));
                        p = gcj02tobd09(p[0], p[1]);
                        var start = new BMap.Point(p[0], p[1]);
                        var end = new BMap.Point(116.80933, 40.3221);
                        var opts = {
                            position: start, // 指定文本标注所在的地理位置
                            offset: new BMap.Size(-(detailObj.GCMC.length * 13) / 2, 10) //设置文本偏移量
                        }
                        var label = new BMap.Label(detailObj.GCMC, opts); // 创建文本标注对象
                        label.setStyle({
                            color: "red",
                            fontSize: "12px",
                            height: "20px",
                            lineHeight: "20px",
                            fontFamily: "微软雅黑"
                        });
                        map.addOverlay(label);
                        var xnmc = "密云区河南寨镇荆栗园村渣土消纳场所"
                        var opts1 = {
                            position: end, // 指定文本标注所在的地理位置
                            offset: new BMap.Size(-(xnmc.length * 13) / 2, 10) //设置文本偏移量
                        }
                        var label1 = new BMap.Label(xnmc, opts1); // 创建文本标注对象
                        label1.setStyle({
                            color: "red",
                            fontSize: "12px",
                            height: "20px",
                            lineHeight: "20px",
                            fontFamily: "微软雅黑"
                        });
                        map.addOverlay(label1);
                        var myIcon = new BMap.Icon("images/siteBule30X30.png", new BMap.Size(20, 20)); // 设置图片偏移
                        myIcon.setImageSize(new BMap.Size(20, 20));
                        var marker = new BMap.Marker(start, { offset: new BMap.Size(0, 0), icon: myIcon });
                        map.addOverlay(marker); //
                        var myIcon1 = new BMap.Icon("images/ztc2.png", new BMap.Size(20, 20)); // 设置图片偏移
                        myIcon.setImageSize(new BMap.Size(20, 20));
                        var marker1 = new BMap.Marker(end, { offset: new BMap.Size(0, 0), icon: myIcon1 });
                        map.addOverlay(marker1); //
                        getGJinof(start, end, detailObj.functions.GJinof);
                        map.centerAndZoom(start, 10);
                    } else {
                        // alert("暂无消纳路线")
                        var p = wgs84togcj02(Number(point[1]), Number(point[0]));
                        p = gcj02tobd09(p[0], p[1]);
                        map.centerAndZoom(new BMap.Point(p[0], p[1]), 14);
                        map.enableScrollWheelZoom(); //启用滚轮放大缩小，默认禁用
                        map.enableContinuousZoom(); //启用地图惯性拖拽，默认禁用
                        var start = new BMap.Point(p[0], p[1]);
                        var mar = new BMap.Marker(new BMap.Point(p[0], p[1]));
                        map.addOverlay(mar)


                    }

                }
            })


        },
        initCondition: function() {
            $("#report").off("click").on("click", function() {
                    layui.use('layer', function() {
                        var layer = layui.layer;
                        layer.open({
                            type: 2,
                            fixed: true,
                            title: ['渣土车研判报告列表', 'font-size: 22px;color: rgb(49, 70, 89);'],
                            closeBtn: 1,
                            scrollbar: false,
                            maxmin: false,
                            content: '/vias_app/views/vias/urbanManagementLawEnforcement/chgzhf/reportOnlinePreview.html',
                            area: ['1000px', '800px'],
                            end: function() {}
                        });
                    });
                })
                //显示无牌车添加事件获取点击的值
            layui.use(['layer', 'form'], function() {
                var layer = layui.layer,
                    $ = layui.jquery,
                    form = layui.form; //必须先声明 
            });
        },
        tzztc: function() {
            window.open("http://11.16.127.79/vias_app/views/vias/snapshot/ztc/ztc.html?token=undefined&subMenu=ztcwf&user=undefined&screeType=undefined&devid=" + detailObj.ztcdevid + "&beginTime=" + detailObj.functions.getDateStr(-1) + " 09:00:00" + "&endTime=" + detailObj.functions.getDateStr(0) + " 09:00:00" + "&cardval=true");
        },
        zyz: function(z) {
            var begintime = detailObj.functions.getDateStr(-10) + " 00:00:00";
            var endtime = detailObj.functions.getCurrentDay();
            detailObj.zyz = z;
            detailObj.page = 1;
            $.ajax({
                type: 'get',
                dataType: "json",
                data: {
                    page: detailObj.page,
                    rows: 9,
                    plateNo: "",
                    vehicleBrand: "",
                    beginTime: begintime,
                    endTime: endtime,
                    vehicleColor: "",
                    plateColor: "",
                    showNoPlate: false,
                    sourceID: "",
                    deviceId: detailObj.ztcdevid,
                    labelTypes: "",
                    userName: "jgp",
                    isZYZ: detailObj.zyz,
                    defaultAlgorithm: false,
                    baiDuAlgorithm: false,
                    yiSaAlgorithm: false,
                    allAlgorithm: true,
                },
                url: 'http://11.16.127.79:8013/VIAS/web/ztc/findZtcData',
                success: function(data) {
                    if (data.rows.length > 0) {
                        detailObj.dataArr = data.rows;
                        detailObj.totalPages = data.totalPages;
                        var rightHTML = [];
                        len = data.rows.length;
                        for (var i = 0; i < len; i++) {
                            var html_ = `<div class="gdxx_btm_item" onclick="detailObj.functions.showmotor('${data.rows[i].SS_ID}','${data.rows[i].PASS_TIME}','${data.rows[i].DEVICE_ID}','${begintime}',this,'${data.rows[i].PLATE_NO}','${data.rows[i].PLATE_COLOR}')">
                            <p class="cph">${data.rows[i].PASS_TIME}</p>
                            <img src="${data.rows[i].STORAGE_URL3}">
                            <p>${data.rows[i].SS_APE_NAME}</p>
                        </div>`
                            rightHTML.push(html_);
                        }
                        $("#record").empty().html(rightHTML.join(''));
                    } else {
                        var noResult = '<div class="list_res_empty" style="height:2.9rem;position:relative;clear:both;">' +
                            ' <div style="width:1.42rem;height:1.75rem;position:absolute;top: 3.8rem;left: 4.8rem;margin:-0.87rem -0.71rem;background:url(images/list_res_empty.png) center center no-repeat;background-size:contain;"></div>' +
                            ' </div>';
                        $("#record").empty();
                        $("#record").append(noResult);
                    }
                }
            });
        },
        prevDetail: function() {
            if (detailObj.fanwei != 0) {
                if (detailObj.tppage > 1) {
                    detailObj.tppage -= 1;
                    $("#myVideo").css("display", "none");
                    $("#img").css("display", "block");
                    $("#img").attr('src', 'gdtp/' + detailObj.num + '/fanwei/' + detailObj.num + '_0' + detailObj.tppage + '.jpg');
                } else if (detailObj.tppage == 1 && detailObj.num == "4") {
                    $("#img").css("display", "none");
                    $("#myVideo").css("display", "block");
                    $("#myVideo").attr("src", "video/gongdi1.mp4");
                } else {
                    $("#img").attr('src', 'gdtp/' + detailObj.num + '/fanwei/' + detailObj.num + '_0' + detailObj.tppage + '.jpg');

                }
            }

        },
        bayonet: function(event) {
            var parma = "";
            if (event.geometry != null) {
                parma = '?deviceId=' + event.geometry.devid;
            } else {
                parma = '?deviceId=' + event.getAttribute("devid");
            }

            layui.use('layer', function() {
                var layer = layui.layer;
                layer.open({
                    type: 2,
                    fixed: true,
                    title: ['卡口详情：<span style="font-size:15px">' + event.getAttribute("devname") + '</span>', 'font-size: 22px;color: rgb(49, 70, 89);'],
                    closeBtn: 1,
                    scrollbar: false,
                    maxmin: false,
                    content: 'jiaotong/shishiSP1.html' + parma,
                    area: ['50%', '75%'],
                    cancel: function(index, layero) {
                        detailObj.functions.stopflv();
                    }

                });
            });
        }

        ,
        bayonetwkk: function(event) {
            var parma = "";
            if (event.geometry != null) {
                parma = '?deviceId=' + event.geometry.devid;
            } else {
                parma = '?deviceId=' + event.getAttribute("devid");
            }

            layui.use('layer', function() {
                var layer = layui.layer;
                layer.open({
                    type: 2,
                    fixed: true,
                    title: ['卡口详情 <span style="font-size:15px">' + event.getAttribute("devname") + '</span>', 'font-size: 22px;color: rgb(49, 70, 89);'],
                    closeBtn: 1,
                    scrollbar: false,
                    maxmin: false,
                    content: 'jiaotong/shishiSP.html' + parma,
                    area: ['100%', '100%'],
                    cancel: function(index, layero) {
                        detailObj.functions.stopflvwkk();
                    }
                });
            });
        },
        spkinof: function() {

            var point = this.getUrlParam("point");
            point = point.split(",");
            $.ajax({
                type: "get",
                dataType: "json",
                async: false,
                data: {
                    httpurl:"roadseg?index=dugis_ut_awkk&type=default&location=" +  point[0]+ "," + point[1] +"&radius=" + 1000 + "&output=json&page_size=10000"
                },
                url: "http://11.16.127.79:5013/VIAS/web/snapshot/baidu/CircularSearch",
                success: function(data) {
                    if (data.status == 0) {
                        data.results.reverse();
                        var data1=unique(data.results);
                        $.each(data1, function(i, row1) {
                            var num=0;
                            if(IsBXKK(row1.devId)==0){
                            if (detailObj.dwData1.length > 0) {
                                $.each(detailObj.dwData1, function(i, row) {
                                    
                                        if (row1.devId == row.DEVICE_ID && row.TYPE == 2) {
                                            num=1;
                                            row1.bayonet += 2;
                                            detailObj.devid.unshift(row1);
                                        }  
                                 })
                                if(num!=1){
                                    detailObj.devid.push(row1);
                                }
                            }else {
                                detailObj.devid.push(row1);
                            }
                            } 


                        })
                    }
                    //展示数据
                    detailObj.functions.spkin();
                }

            })


        },

        spkinof1: function() {
            $.ajax({
                type: 'get',
                dataType: "JSON",
                contentType: "application/json",
                data: {
                    id: getUrlParam("gdid")
                },
                url: GDUrl + "/VIAS/web/snapshot/WorkSite/queryInfoById",
                success: function(data) {
                    console.log(data)
                    $.each(data, function(i, row) {
                        detailObj.dwData1.push(row);
                        if (i == data.length - 1) {
                            detailObj.ztcdevid += row.DEVICE_ID;
                        } else {
                            detailObj.ztcdevid += row.DEVICE_ID + ",";
                        }

                    })

                    detailObj.functions.spkinof();
                }
            });
            var point = this.getUrlParam("point");
            point = point.split(",");
            $.ajax({
                type: 'get',
                dataType: "json",
                data: {
                    httpurl: '/cloudSearch/search/nearby?location=' + point[1] + "," + point[0] + '&radius=1000&table=awkk1&page_number=1&page_size=1000&data_type=2'
                },
                url: siteUrl_ports + '/VIAS/web/snapshot/baidu/CircularSearch',
                success: function(data) {
                    for (i in data.data.list) {
                        detailObj.deviceIds = detailObj.deviceIds + data.data.list[i].devId + ","
                    }
                    detailObj.deviceIds = detailObj.deviceIds.substring(0, detailObj.deviceIds.length - 1)
                    detailObj.functions.getztcdata();
                }

            });

        },
        spkinof12: function() {
            $.ajax({
                type: 'get',
                dataType: "JSON",
                contentType: "application/json",
                data: {
                    GDID: getUrlParam("gdid")
                },
                //siteUrl_port
                url: siteUrl_port + "/VIAS/web/site/selectINLOOKByGDID",
                success: function(data) {
                    console.log(data)
                    var num = 0;
                    var _html = "";
                    if (data !== null && data.length > 0) {
                        $.each(data, function(i, rows) {
                            num += 1;
                            _html += `<div class="spl_res_item"  onclick="detailObj.functions.bayonet(this);" devname="${rows.SBMC}"  devid="${rows.SBBH}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon"><img src="images/qji2.png"><img src="images/sp_licon3.png"></div><div class="spl_res_txt"><h4  title="${rows.SBMC}">${rows.SBMC}</h4><p>微卡口</p><p>${rows.SSJD}</p></div></div>`;
                        })
                        $("#kknum2").text("(" + num + ")");
                        $("#total2").text(num);
                        $("#sql_con2").empty();
                        $("#spl_con2").html(_html);
                    } else {
                        $(".gdxx_btn2").attr("style", "display:none;"); //隐藏div
                        $("#spl_res2").attr("style", "display:none;"); //隐藏div
                    }
                }
            });
        },
        spkin: function() {
            var num = 0;
            var _html = "";
            $.each(detailObj.devid, function(i, rows) {
                if (rows.bayonet == 0) {
                    num += 1;
                    _html += `<div class="spl_res_item"  onclick="detailObj.functions.bayonet(this);" devname="${rows.devName}"  devid="${rows.devId}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon"><img src="images/qji2.png"><img src="images/sp_licon3.png"></div><div class="spl_res_txt"><h4  title="${rows.devName}">${rows.devName}</h4><p>非微卡口</p><p>${rows.streetname}</p></div></div>`;
                } else if (rows.bayonet == 1) {
                    _html += `<div class="spl_res_item"  onclick="detailObj.functions.bayonetwkk(this);" devname="${rows.devName}" devid="${rows.devId}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon" ><img src="images/wkk4.png"><img src="images/sp_licon3.png"></div><div class="spl_res_txt"><h4  title="${rows.devName}">${rows.devName}</h4><p>微卡口</p><p>${rows.streetname}</p></div></div>`;
                    num += 1;
                } else if (rows.bayonet == 2) {
                    num += 1;
                    _html += `<div class="spl_res_item"  onclick="detailObj.functions.bayonet(this);" devname="${rows.devName}"  devid="${rows.devId}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon"><img src="images/qji2.png"><img src="images/sp_licon3.png"></div><div class="spl_res_txt"><h4  title="${rows.devName}" style="color:red;">${rows.devName}</h4><p>非微卡口</p><p>${rows.streetname}</p></div></div>`;

                } else if (rows.bayonet == 3) {
                    _html += `<div class="spl_res_item"  onclick="detailObj.functions.bayonetwkk(this);" devname="${rows.devName}" devid="${rows.devId}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon" ><img src="images/wkk4.png"><img src="images/sp_licon3.png"></div><div class="spl_res_txt"><h4 style="color:red;" title="${rows.devName}">${rows.devName}</h4><p>微卡口</p><p>${rows.streetname}</p></div></div>`;
                    num += 1;

                }

            })
            $("#kknum").text("(" + num + ")");
            $("#total").text(num);
            $("#sql_con").empty();
            $("#spl_con").html(_html);

        },
        spk: function() {
            var devid = "";
            if (detailObj.bool == 1 && detailObj.bool2 == 0) {
                $(".gdxx_btn").css("right", "0rem");
                $(".gdxx_btn2").css("right", "0rem");

                $("#spl_res1").css("right", "-4.5rem");
                $("#spl_res2").css("right", "-4.5rem");
                detailObj.bool = 0;
            } else if (detailObj.bool == 0 && detailObj.bool2 == 0) {
                $(".gdxx_btn").css("right", "4rem");
                $(".gdxx_btn2").css("right", "4rem");

                $("#spl_res1").css("right", "0rem");
                $("#spl_res2").css("right", "-4.5rem");
                detailObj.bool = 1;
            } else if (detailObj.bool == 1 && detailObj.bool2 == 1) {
                $(".gdxx_btn").css("right", "0rem");
                $(".gdxx_btn2").css("right", "0rem");
                $("#spl_res1").css("right", "-4.5rem");
                $("#spl_res2").css("right", "-4.5rem");

                detailObj.bool = 0;
                detailObj.bool2 = 0;

            } else if (detailObj.bool == 0 && detailObj.bool2 == 1) {
                $(".gdxx_btn").css("right", "4rem");
                $(".gdxx_btn2").css("right", "4rem");
                $("#spl_res1").css("right", "0rem");
                $("#spl_res2").css("right", "-4.5rem");
                detailObj.bool2 = 0;
                detailObj.bool = 1;
            }
        },
        spk2: function() {
            var devid = "";
            if (detailObj.bool == 1 && detailObj.bool2 == 0) {
                $(".gdxx_btn").css("right", "4rem");
                $(".gdxx_btn2").css("right", "4rem");

                $("#spl_res2").css("right", "0rem");
                $("#spl_res1").css("right", "-4.5rem");
                detailObj.bool2 = 1;
                detailObj.bool = 0;
            } else if (detailObj.bool == 0 && detailObj.bool2 == 0) {
                $(".gdxx_btn").css("right", "4rem");
                $(".gdxx_btn2").css("right", "4rem");

                $("#spl_res2").css("right", "0rem");
                $("#spl_res1").css("right", "-4.5rem");
                detailObj.bool2 = 1;
            } else if (detailObj.bool == 1 && detailObj.bool2 == 1) {
                $(".gdxx_btn").css("right", "0rem");
                $(".gdxx_btn2").css("right", "0rem");

                $("#spl_res1").css("right", "-4.5rem");
                $("#spl_res2").css("right", "-4.5rem");

                detailObj.bool = 0;
                detailObj.bool2 = 0;

            } else if (detailObj.bool == 0 && detailObj.bool2 == 1) {
                $(".gdxx_btn").css("right", "0rem");
                $(".gdxx_btn2").css("right", "0rem");
                $("#spl_res1").css("right", "-4.5rem");
                $("#spl_res2").css("right", "-4.5rem");
                detailObj.bool2 = 0;
            }
        },
        nextDetail: function() {
            if (detailObj.fanwei != 0) {
                if (detailObj.tppage < detailObj.fanwei) {
                    detailObj.tppage += 1;
                    $("#myVideo").css("display", "none");
                    $("#img").css("display", "block");
                    $("#img").attr('src', 'gdtp/' + detailObj.num + '/fanwei/' + detailObj.num + '_0' + detailObj.tppage + '.jpg');
                } else {
                    $("#img").attr('src', 'gdtp/' + detailObj.num + '/fanwei/' + detailObj.num + '_0' + detailObj.tppage + '.jpg');

                }
            }
        },
        stopflv: function() {
            var loginid = window.sessionStorage.getItem("videoDisplayLoginID");
            var session = window.sessionStorage.getItem("videoSession");
            if (loginid) {
                if (session != "undefined") {
                    $.ajax({
                        type: 'POST',
                        dataType: "JSON",
                        contentType: "application/json",
                        data: JSON.stringify({ "LoginID": loginid, "Session": session }),
                        url: "http://11.16.127.79:8013/Video/stopreal",
                        success: function(data) {
                            console.log(data)
                                // logout(loginid);
                        }
                    });
                } else {
                    // logout(loginid);
                }
            }
        },
        stopflvDe: function() {

            var loginid = loginId;
            var session = sessionId;
            console.log("loginid:" + loginid + ",session:" + session)
            $.ajax({
                type: 'POST',
                dataType: "JSON",
                async: false,
                contentType: "application/json",
                data: JSON.stringify({ "LoginID": loginid, "Session": session }),
                //url: "http://11.16.127.79:8013/Video/stopreal",
                url: ssspObj.videoStopUrl,
                success: function(data) {
                    console.log(data)
                }
            });

        },
        logout: function(loginid) {

            $.ajax({
                url: 'http://11.16.127.79:8013/Video/logout',

                type: 'post',

                contentType: "application/json",
                  //必须有
                dataType: "json",
                  //表示返回值类型，不必须
                data: JSON.stringify({ "LoginID": loginid }),
                success: function(data) {
                    console.log(data);
                }
            });
        },
        logoutDe: function() {
            var loginid = loginId;
            console.log(loginid);
            $.ajax({
                //      url: 'http://11.16.127.79:8013/Video/logout',
                url: ssspObj.videoLogoutUrl,
                type: 'post',
                async: false,
                contentType: "application/json",
                  //必须有
                dataType: "json",
                  //表示返回值类型，不必须
                data: JSON.stringify({ "LoginID": loginid }),
                success: function(data) {
                    console.log(data);
                }
            });
        },
        stopflvwkk: function() {
            var loginid = window.sessionStorage.getItem("wkkvideoDisplayLoginID");
            var session = window.sessionStorage.getItem("videoSession");
            if (loginid) {
                if (session != "undefined") {
                    $.ajax({
                        type: 'POST',
                        dataType: "JSON",
                        contentType: "application/json",

                        data: JSON.stringify({ "LoginID": loginid, "Session": session }),
                        url: "http://11.16.127.79:8013/Video/stoprealwkk",
                        success: function(data) {
                            console.log(data)
                                // logoutwkk(loginid);
                        }
                    });
                } else {
                    // logoutwkk(loginid);
                }
            }
        },
        logoutwkk: function(loginid) {
            $.ajax({
                url: 'http://11.16.127.79:8013/Video/logoutwkk',
                type: 'post',
                contentType: "application/json",
                  //必须有
                dataType: "json",
                  //表示返回值类型，不必须
                data: JSON.stringify({ "LoginID": loginid }),
                success: function(data) {
                    console.log(data);
                }
            });
        },
        showmotor: function(ssid, time, device_id, beginTime, obj, plateNo, plateColor) {
            var parma = '?ssid=' + encodeURIComponent(ssid) +
                '&time=' + encodeURIComponent(time) +
                '&deviceId=' + encodeURIComponent(device_id) +
                '&beginTime=' + encodeURIComponent(beginTime) +
                '&plateNo=' + encodeURIComponent(plateNo) +
                '&plateColor=' + encodeURIComponent(plateColor) +
                '&parentObj=detailObj';
            detailObj.index = $(obj).index();
            detailObj.plateColor = plateColor;
            layui.use('layer', function() {
                var layer = layui.layer;
                layer.open({
                    type: 2,
                    fixed: true,
                    title: ['一车一档详情', 'font-size: 22px;color: rgb(49, 70, 89);'],
                    closeBtn: 1,
                    scrollbar: false,
                    maxmin: false,
                    content: '/vias_app/views/vias/snapshot/ztc/oneCarToInfo.html' + parma,
                    area: ['100%', '100%'],
                    end: function() {
                        // 暂时不用
                    }
                });
            });
        },
        getzyzAction: function() {
            var obj = document.getElementsByName("zyzCheck");
            var check_val = [];
            if (obj.length > 0) {
                for (k in obj) {
                    if (obj[k].checked)
                        check_val.push(Number(k) + 1);
                }
                return check_val.join(',');
            } else {
                return "";
            }


        },
        //获取url后的参数值
        getUrlParam: function(key, url) {
            var href = url || window.location.href;
            var url = href.split("?");
            if (url.length <= 1) {
                return "";
            }
            var params = url[1].split("&");

            for (var i = 0; i < params.length; i++) {
                var param = params[i].split("=");
                if (key == param[0]) {
                    if (url[2] != undefined) {
                        return decodeURIComponent(param[1] + '?' + url[2]);
                    }
                    return decodeURIComponent(param[1]);
                }
            }
        }, //获取前后的时间  返回的时间格式为'2018-04-28 00:00:00'  n为正数 往后n天  n为负数 往前n天
        getCurrentDay: function(n) {
            var today = new Date(),
                date;
            return n ? (new Date(today.getTime() + n * 1000 * 60 * 60 * 24)).pattern("yyyy-MM-dd HH:mm:ss") : new Date().pattern("yyyy-MM-dd HH:mm:ss")
        },
        confirmEnding: function(str, target) {
            // 请把你的代码写在这里
            var start = str.length - target.length;
            var arr = str.substr(start, target.length);
            if (arr == target) {
                return true;
            }
            return false;
        },
        getDateStr: function(AddDayCount) {
            var dd = new Date();
            dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
            var y = dd.getFullYear();
            var m = (dd.getMonth() + 1) < 10 ? "0" + (dd.getMonth() + 1) : (dd.getMonth() + 1); //获取当前月份的日期，不足10补0
            var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate(); //获取当前几号，不足10补0
            return y + "-" + m + "-" + d;
        },
        getztcdata: function() {
            var begintime = "2019-08-24 00:00:00";
            var endtime = detailObj.functions.getCurrentDay();
            console.log(detailObj.ztcdevid + "---------------------------");

            $.ajax({
                type: 'get',
                dataType: "json",
                data: {
                    page: detailObj.page,
                    rows: 6,
                    plateNo: "",
                    vehicleBrand: "",
                    beginTime: begintime,
                    endTime: endtime,
                    vehicleColor: "",
                    plateColor: "",
                    showNoPlate: true,
                    sourceID: "",
                    deviceId: getUrlParam("isgdid") != '1' ? detailObj.deviceIds : detailObj.gdid,
                    labelTypes: "",
                    userName: "jgp",
                    isZYZ: "",
                    defaultAlgorithm: false,
                    baiDuAlgorithm: false,
                    yiSaAlgorithm: false,
                    allAlgorithm: true,
                },
                url: 'http://11.16.127.79:8013/VIAS/web/ztc/findByMuckTruckLeaderUse',
                success: function(data) {
                    console.log(data);
                    if (data.rows.length > 0) {
                        detailObj.dataArr = data.rows;
                        detailObj.totalPages = data.totalPages;
                        var rightHTML = [];
                        len = data.rows.length;
                        for (var i = 0; i < len; i++) {
                            var html_ = `<div class="gdxx_btm_item" onclick="detailObj.functions.showmotor('${data.rows[i].SS_ID}','${data.rows[i].PASS_TIME}','${data.rows[i].DEVICE_ID}','${begintime}',this,'${data.rows[i].PLATE_NO}','${data.rows[i].PLATE_COLOR}')">
                            <p class="cph">${data.rows[i].PASS_TIME}</p>
                            <img src="${data.rows[i].STORAGE_URL3}">
                            <p>${data.rows[i].SS_APE_NAME}</p>
                        </div>`
                            rightHTML.push(html_);
                        }
                        $("#record").empty().html(rightHTML.join(''));
                    } else {
                        var noResult = '<div class="list_res_empty" style="height:2.9rem;position:relative;clear:both;">' +
                            ' <div style="width:1.42rem;height:1.75rem;position:absolute;top: 3.8rem;left: 4.8rem;margin:-0.87rem -0.71rem;background:url(images/list_res_empty.png) center center no-repeat;background-size:contain;"></div>' +
                            ' </div>';
                        $("#record").empty();
                        $("#record").append(noResult);
                    }
                }
            });
        }

    }
}